<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>上传形象数据</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <!--weui.min.css-->
    <link rel="stylesheet" href="/static/index/css/page/base.css"/>
    <link rel="stylesheet" href="/static/index/css/page/font.css"/>
    <link rel="stylesheet" href="/static/index/jquery_weui/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/lib/weui.min.css">
    <!--jquery-weui.min.css-->
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/css/jquery-weui.min.css">
    <link rel="stylesheet" href="/static/index/css/page/add.css" />
</head>
<body>
<div class="pageControl data bg-f5">
    <!--主体-->
    <div class="main">
        <div class="bg-di"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">上传形象数据</h1>
        </div>
    </div>
    <div class="data-top">
        <p class="text-center cl-3333">在这里，没有<span>真实头像</span>的人 </p>
        <p class="text-center cl-3333">是交不到朋友的</p>
    </div>
    <div class="data-img">
        <div class="weui-cell userImg">
            <div class="weui-cell__hd">
                <img id="newimg" src="{$info.img}" alt="">
            </div>
            <div class="weui-cell__bd">
                <p>优先展示</p>
                <p>每天访问流量<span>99+</span></p>
                <p>热度值火爆，提升<span>8.6</span>倍</p>
            </div>
        </div>
    </div>
    <div class="data-btn">
        <div class="pl">
            <div class="file_div">从相册选择</div>
            <input class="file tpinfo" type="file" value="从相册选择"/>
        </div>
        <div class="pl">
            <div>拍照</div>
            <input class="tpinfo file" type="file" name="photos[]" accept="image/*" multiple id="subinfo" capture="camera"/>
        </div>
        <div id="header_index">前往首页</div>
        <a href="/index/personal/personal_info?id={$id}" id="next">下一步</a>
    </div>
</div>
<!-- jquery-2.1.4 -->
<script type="text/javascript" src="/static/index/jquery_weui/lib/jquery-2.1.4.js"></script>
<!-- jquery-weui.min.js -->
<script type="text/javascript" src="/static/index/jquery_weui/js/jquery-weui.min.js"></script>
<script src="/static/index/jquery_weui/js/swiper.min.js"></script>
<script>
	//编辑头像
    $(".tpinfo").change(function(){
    	var id = {$id};
        var filess = this.files[0];
        var src=getObjectURL(filess);//获取上传文件的路径
        $("#newimg").attr("src",src);
        var formData = new FormData();
        formData.append("fb_img",this.files[0]);
        var url = "/index/Personal/mcupload";
        var url2 = "/index/personal/uphead";
        $.ajax({
            url:url,
            data:formData,
            processData: false,
            contentType: false,
            type:"post",
            success:function(data){
            	
                $.ajax({
                	url:url2,
                	data:{img:data,id:id},
                	type:'post',
                	success:function(int){
                		if(int == "1") {
                             alert("头像修改成功");
                        }else if(int == "-1"){
                             alert("修改失败");
                        }
                	}
                })
                
            },
            error:function(e){

            }
        });
    });
    $('#header_index').click(function(){
        var id = {$id};
        $.post(
            "/index/personal/header_index",
            {id:id},
            function(data){
                if(data == 1){
                    window.location.href="/index/index/index";
                }
            }
        )
    })
      //获取上传文件的url
    function getObjectURL(file)
    {
        var url = null;
        if (window.createObjectURL != undefined)
        {
            url = window.createObjectURL(file);
        }
        else if (window.URL != undefined)
        {
            url = window.URL.createObjectURL(file);
        }
        else if (window.webkitURL != undefined)
        {
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }	
</script>
</body>
</html>

